{% extends 'main.html' %}
{% load func %}

{% block title %}
    <title>tag admin</title>
{% endblock %}


{% block content %}

<div class="row demo-mh-byrow">
{% for notepad in notepad_obj %}
    <div class="col-md-6">
        <div class="panel panel-colorful panel-default" style="height: 209.261px;">
            <div class="panel-heading">
                <h3 class="panel-title">{{ notepad.title }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="label label-warning">{{ notepad.date }}</label><button class="btn btn-active-purple" onclick="choices(this)" id="{{ notepad.id }}">设为已读</button></h3>
            </div>
            <div class="pad-all">
                <p>{{ notepad.content }}</p>
            </div>
        </div>
    </div>
{% endfor %}
</div>

<div class="panel-body ">
    <div class="panel-heading ">
        <h3 class="panel-title">增加新备忘事件</h3>
    </div>
    <div class="panel">
        <form class="form-horizontal" method="POST">
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-sm-3 control-label" for="demo-is-inputsmall">标题</label>
                    <div class="col-sm-6">
                    <p><input class="form-control input-sm"  maxlength="255" name="title" type="text" required=""></p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" for="demo-is-inputsmall">正文</label>
                    <div class="col-sm-6">
                    <p><input class="form-control input-sm"  maxlength="255" name="content" type="text" required=""></p>
                    </div>
                </div>

            </div>
            <div class="panel-footer">
                <div class="row">
                    <div class="col-sm-9 col-sm-offset-3">
                        <button class="btn btn-mint" type="submit" >保存</button>
                        <button class="btn btn-warning" type="reset">重填</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
   function del(eml){
        var tag_id=$(eml).attr('id');
        if(confirm('是否删除标签？删除前请保证无资产关联到此标签，否则会导致失败')){
            $.ajax({
                url:'/tag_mgr/',
                type:'DELETE',
                data:{'tag_id':tag_id},
                success:function(arg){
                    if(arg == 0){
                        location.reload()
                    }
                    else {
                        $('#error').text('删除失败！！请先删除关联到此标签的资产！！')
                    }
                }
            })
        }
    }

    function choices (eml){
        var Nt_id=$(eml).attr('id');
        $.ajax({
            url:'/notepad',
            type:'DELETE',
            data:{'Nt_id':Nt_id},
            success:function(){
                location.reload()
            }
        })
    }
</script>
{% endblock %}
